﻿using Sustainalytics.ClientDW.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sustainalytics.Companies
{
    public interface ICompanyMatchingLogic
    {

        /// <summary>
        /// Search for companies by exact match of the terms.
        /// </summary>
        /// <param name="param">
        /// Terms used for company match.
        /// </param>
        /// <param name="skip">
        /// Number of elements to be skipped on paging use null for no usage.
        /// </param>
        /// <param name="take">
        /// Number of elements to be taken on pagin use null for no usage.
        /// </param>
        /// <returns>
        /// A list of company types that matches the params.
        /// </returns>
        List<Company> MatchCompanies(int skip, int take, string term, bool searchInName = true);

        /// <summary>
        /// This method will be used only on portfolio with dedication.
        /// </summary>
        /// <param name="ICollection<Guid> ids"></param>
        /// <returns></returns>
        IList<int> FindCapitalIdIdsForCompanies(ICollection<Guid> ids);

        /// <summary>
        /// Search for CapitalIqId by Guid.
        /// </summary>
        /// <param name="Guid id"></param>
        /// <returns>
        /// CapitalIqId.
        /// </returns>
        int FindCapitalIqIdForGuid(Guid id);

        /// <summary>
        /// Search for SecurityId by capitalIqId.
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns>
        /// SecurityId.
        /// </returns>
        string FindSecurityIdForCompanyId(int companyId);

        /// <summary>
        /// Search for Guid for a Company.
        /// </summary>
        /// <param name="company"></param>
        /// <returns>
        /// Guid
        /// </returns>
        Guid FindGuidForOneCompany(Company company);

        /// <summary>
        /// Search for CompanyNameFriendlyURL for a company that has a capitalIqId.
        /// </summary>
        /// <param name="capitalIqId"></param>
        /// <returns>
        /// CompanyNameFriendlyURL.
        /// </returns>
        string FindCompanyNameFriendlyURLForId(int capitalIqId);

        /// <summary>
        /// Returns the first company match by value of the identifier and identifier type. When searching by company identifier <see cref="IdentifierType"/> it will not look for exact match.
        /// </summary>
        /// <param name="type">
        /// Identifer type <see cref="IdentifierType"/> and IdentifierValue.
        /// </param>
        /// <param name="param">
        /// Terms used for company search, in this method it will look only in IdentifierValue.
        /// </param>
        /// <returns>        
        /// First company search match by this params.If not found it will throw <see cref="CompanyNotFoundException"/>.
        /// </returns
        int FindOneCompanyByIdentifier(IdentifierType type, string param);

        /// <summary>
        /// Search for companies by capitalIqId and returns their coresponding Company.
        /// </summary>
        /// <param name="capitalIqId">
        /// </param>
        /// <returns>
        /// A list of Company.
        /// </returns>
        IList<Company> GetCompanySearchByCompanyId(int capitalIqId);

        /// <summary>
        /// Returns the company main ISIN associated with the main security
        /// </summary>
        /// <param name="companyId">
        ///     Collections of capitalIqIds
        /// </param>
        /// <returns>
        /// List of Comany. 
        /// </returns>
        IList<Company> GetCompaniesSearchByCompanyId(ICollection<int> capitalIqIds);

    }
}
